var DatatableRemoteAjaxDemo = {
	init: function() {
		var t;
		t = $(".m_datatable").mDatatable({
			data: {
				type: "remote",//获取远程数据
				source: {
					read: {//数据url
						url: "https://www.easy-mock.com/mock/5b31e1be08040624bfc1c834/matrix_v1.0/getTableData",
						method: 'GET',
						params: {
		                    // 查询参数
		                    generalSearch: '',
		                    EmployeeID: 1,
		                    someParam: 'someValue',
		                    token: 'token-value'
		                },
						map: function(t) {
							var e = t;
							return void 0 !== t.data && (e = t.data), e
						}
					}
				},
				pageSize: 10,
				serverPaging: true,
				serverFiltering: !0,
				serverSorting: !0
			},
			 
			layout: {
				scroll: !1,
				footer: !1
			},
			sortable: !0,
			pagination: !0,
			toolbar: {
				items: {
					pagination: {
						pageSizeSelect: [10, 20, 30, 50, 100]
					}
				}
			},
			search: {
			      // enable trigger search by keyup enter
			      onEnter: false,
			      // input text for search
			      input: $('#generalSearch'),
			      // search delay in milliseconds
			      delay: 400,
			    },
			columns: [{
				field: "RecordID",
				title: "#",
				sortable: !1,
				width: 40,
				selector: !1,
				textAlign: "center"
			}, {
				field: "OrderID",
				title: "Order ID",
				filterable: !1,
				width: 150,
				template: "{{OrderID}} - {{ShipCountry}}"
			}, {
				field: "ShipCountry",
				title: "Ship Country",
				attr: {
					nowrap: "nowrap"
				},
				width: 150,
				template: function(t) {
					return t.ShipCountry + " - " + t.ShipCity
				}
			}, {
				field: "ShipCity",
				title: "Ship City"
			}, {
				field: "Currency",
				title: "Currency",
				width: 100
			}, {
				field: "ShipDate",
				title: "Ship Date",
				type: "date",
				format: "MM/DD/YYYY"
			}, {
				field: "Latitude",
				title: "Latitude",
				type: "number"
			}, {
				field: "Status",
				title: "Status",
				template: function(t) {
					var e = {
						1: {
							title: "Pending",
							class: "m-badge--brand"
						},
						2: {
							title: "Delivered",
							class: " m-badge--metal"
						},
						3: {
							title: "Canceled",
							class: " m-badge--primary"
						},
						4: {
							title: "Success",
							class: " m-badge--success"
						},
						5: {
							title: "Info",
							class: " m-badge--info"
						},
						6: {
							title: "Danger",
							class: " m-badge--danger"
						},
						7: {
							title: "Warning",
							class: " m-badge--warning"
						}
					};
					return '<span class="m-badge ' + e[t.Status].class + ' m-badge--wide">' + e[t.Status].title + "</span>"
				}
			}, {
				field: "Type",
				title: "Type",
				template: function(t) {
					var e = {
						1: {
							title: "Online",
							state: "danger"
						},
						2: {
							title: "Retail",
							state: "primary"
						},
						3: {
							title: "Direct",
							state: "accent"
						}
					};
					return '<span class="m-badge m-badge--' + e[t.Type].state + ' m-badge--dot"></span>&nbsp;<span class="m--font-bold m--font-' + e[t.Type].state + '">' + e[t.Type].title + "</span>"
				}
			}, {
				field: "Actions",
				width: 110,
				title: "操作",
				sortable: !1,
				overflow: "visible",
				template: function(t, e, a) {
					return '\t\t\t\t\t\t<div class="dropdown ' + (a.getPageSize() - e <= 4 ? "dropup" : "") + '">\t\t\t\t\t\t\t<a href="#" class="btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill" data-toggle="dropdown">'+
					'<i class="la la-ellipsis-h"></i></a>\t\t\t\t\t\t  \t<div class="dropdown-menu dropdown-menu-right">\t\t\t\t\t\t    \t'+
					'<a class="dropdown-item editBtn" href="javascript:void(0);" ><i class="la la-edit"></i> 编辑</a>\t\t\t\t\t\t    \t'+
					'<a class="dropdown-item updateBtn" href="javascript:void(0);"><i class="la la-leaf"></i> 更新状态</a>\t\t\t\t\t\t    \t'+
					'<a class="dropdown-item generateBtn" href="javascript:void(0);"><i class="la la-print"></i> 生成报告</a>\t\t\t\t\t\t  \t</div>\t\t\t\t\t\t</div>\t\t\t\t\t\t'+
					'<a href="javascript:void(0);" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill editBtn" title="编辑">\t\t\t\t\t\t\t<i class="la la-edit"></i>\t\t\t\t\t\t</a>\t\t\t\t\t\t'+
					'<a href="javascript:void(0);" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill deleteBtn" title="删除">\t\t\t\t\t\t\t<i class="la la-trash"></i>\t\t\t\t\t\t</a>\t\t\t\t\t'
				}
			}]
		}), $("#m_form_status").on("change", function() {
			t.search($(this).val(), "Status")
		}), $("#m_form_type").on("change", function() {
			t.search($(this).val(), "Type")
		}), $("#m_form_status, #m_form_type").selectpicker()
		
	}
	
};
jQuery(document).ready(function() {
	DatatableRemoteAjaxDemo.init();
	//绑定编辑事件
	$(".m_datatable").on("click",".editBtn",function(ev){
		alert("编辑");
	});
	//绑定删除事件
	$(".m_datatable").on("click",".deleteBtn",function(ev){
		alert("删除");
	})
});